//
//  FindHeadViewCell.m
//  FiveWork
//
//  Created by lanou3g on 15/11/18.
//  Copyright © 2015年 Project. All rights reserved.
//

#import "FindHeadViewCell.h"

#define ViewWidth [UIScreen mainScreen].bounds.size.width

@interface FindHeadViewCell ()

// 头像
@property (nonatomic, strong) UIImageView *imgView;

// 名字
@property (nonatomic, strong) UILabel *nameLabel;

// 距离现在多长时间发布的
@property (nonatomic, strong) UILabel *timeLabel;

// 点赞和评论按钮
@property (nonatomic, strong) UIButton *setButton;

// 发布的文字
@property (nonatomic, strong) UILabel *infoLabel;

// 发布的图片
@property (nonatomic, strong) UIImageView *photoImageView;

// 背景设置
@property (nonatomic, strong) UIButton *bgButton;

// 用户的头像
@property (nonatomic, strong) UIImageView *UserPhotoImage;

// 用户的名字
@property (nonatomic, strong) UILabel *UserLabel;

@end

@implementation FindHeadViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubview];
    }
    return self;
}

- (void) setupSubview
{
    // 背景图片的设置
    // 背景图片的Frame
    CGFloat bgX = 0;
    CGFloat bgY = -100;
    CGFloat bgW = ViewWidth;
    CGFloat bgH = 300;

    // 背景图片的属性设置
    self.bgButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.bgButton.frame = CGRectMake(bgX, bgY, bgW, bgH);
    self.bgButton.backgroundColor = [UIColor blackColor];
    [self addSubview:self.bgButton];
    
    
    // 用户的头像
    // 用户头像的frame
    CGFloat useimgX = 270;
    CGFloat useimgY = 140;
    CGFloat useimgW = 80;
    CGFloat useimgH = useimgW;
    
    // 用户头像的属性设置
    self.UserPhotoImage = [[UIImageView alloc] initWithFrame:CGRectMake(useimgX, useimgY, useimgW, useimgH)];
    self.UserPhotoImage.backgroundColor = [UIColor yellowColor];
    [self addSubview:self.UserPhotoImage];
    
    
    // 用户的名字
    // 用户的名字的frame
    CGFloat useNameX = 100;
    CGFloat useNameY = 160;
    CGFloat useNameW = 150;
    CGFloat useNameH = 50;

    // 用户的名字的属性设置
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(useNameX, useNameY, useNameW, useNameH)];
    self.nameLabel.text = @"1212121";
    self.nameLabel.backgroundColor = [UIColor greenColor];
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.nameLabel];
    
    // 头像
    // 头像的坐标和大小
    CGFloat imgX = 10;
    CGFloat imgY = 240;
    CGFloat imgW = 50;
    CGFloat imgH = imgW;
    
    // 头像属性的设置
    self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(imgX, imgY, imgW, imgH)];
    self.imgView.backgroundColor = [UIColor redColor];
    [self addSubview:self.imgView];
    
    
    // 名字
    // 名字的坐标和大小
    CGFloat nameX = imgX * 2 + imgW;
    CGFloat nameY = imgY;
    CGFloat nameW = self.frame.size.width - nameX;
    CGFloat nameH = 30;
    
    
    // 名字属性的设置
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameX, nameY, nameW, nameH)];
    self.nameLabel.text = @"name";
    self.nameLabel.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.nameLabel];
    
    
    // 发布的文字
    // 文字的坐标和大小
    CGFloat infoX = nameX;
    CGFloat infoY = nameY + nameH + 10;
    CGFloat infoW = nameW;
    CGFloat infoH = nameH * 2;
    
    
    // 文字属性的设置
    self.infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(infoX, infoY, infoW, infoH)];
    self.infoLabel.numberOfLines = 0;
    self.infoLabel.text = @"adsjkljfkldjfkldjf;kladjklsfj;dlskfjdls;fkjl;";
    self.infoLabel.backgroundColor = [UIColor blueColor];
    [self addSubview: self.infoLabel];
    
    
    // 发布的图片
    // 图片的坐标和大小
    CGFloat phoX = infoX;
    CGFloat phoY = infoY + infoH + 10;
    CGFloat phoW = 60;
    CGFloat phoH = 60;
    
    // 图片属性的设置
    self.photoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(phoX, phoY, phoW, phoH)];
    self.photoImageView.backgroundColor = [UIColor magentaColor];
    [self addSubview:self.photoImageView];
    
    
    // 时间
    // 时间的坐标和大小
    CGFloat timeX = nameX;
    CGFloat timeY = phoH + phoY + 10;
    CGFloat timeW = 60;
    CGFloat timeH = 20;
    
    // 时间属性的设置
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeX, timeY, timeW, timeH)];
    self.timeLabel.text = @"17hour";
    [self addSubview:self.timeLabel];
    
    
    // 按钮
    // 按钮的坐标和大小
    CGFloat btnX = 320;
    CGFloat btnY = timeY - 10;
    CGFloat btnW = 50;
    CGFloat btnH = timeH + 10;
    
    self.setButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.setButton.frame = CGRectMake(btnX, btnY, btnW, btnH);
    [self.setButton setTitle:@"Add" forState:UIControlStateNormal];
    self.setButton.backgroundColor = [UIColor redColor];
    [self addSubview:self.setButton];
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
    // Configure the view for the selected state
}

@end
